package com.learning.Map;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class CollectionSort {

    public static Date toDate(String strDate){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return sdf.parse(strDate);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) {
        Student andy = new Student(1,toDate("1993-05-12"),"Andy");
        Student mark = new Student(2,toDate("1990-12-04"),"Mark");
        Student rose = new Student(3,toDate("1997-02-18"),"Rose");
        Student jimmy = new Student(4,toDate("1991-11-15"),"Jimmy");


        List<Student> studentList = Arrays.asList(andy,mark,rose,jimmy);


        /*List<Integer> integerList = new ArrayList<>();
        integerList.add(56);
        integerList.add(13);
        integerList.add(18);
        integerList.add(34);*/

        System.out.println("自然排序之前打印集合中的元素：");
        studentList.forEach(System.out::println);
        Collections.sort(studentList,new BirthdayComparator());
        System.out.println("-------------------------------------------");
        System.out.println("自然排序之后打印集合中的元素：");
        studentList.forEach(System.out::println);
    }
}
